// Data registers in the CAN controller
#define TXB0CTRL	0x30
#define TXB0SIDH	0x31
#define TXB0SIDL	0x32
#define TXB0DLC		0x35
#define TXB0D0		0x36
#define TXB0D1		0x37
#define TXB0D2		0x38

#define TXB1CTRL	0x40
#define TXB1SIDH	0x41
#define TXB1SIDL	0x42
#define TXB1DLC		0x45
#define TXB1D0		0x46
#define TXB1D1		0x47
#define TXB1D2		0x48

#define RXB0SIDH	0x61
#define RXB0SIDL	0x62
#define RXB0DLC		0x65
#define RXB0D0		0x66

#define RXB1SIDH	0x71
#define RXB1SIDL	0x72
#define RXB1DLC		0x75
#define RXB1D0		0x76

// CAN buffers
#define BUFFER0		0x01
#define BUFFER1		0x02
#define BUFFER2		0x04

// CAN message struct
typedef struct
{
	unsigned short id;
	uint8_t length;
	uint8_t data[8];
} can_message_t;

#define GROUP 14

// CAN interrupt IDs
#define WII			0x50
#define JOY_COORDS	0x11
#define ADD_POINT	0x12
#define SHOOT		0x13
#define MOTOR		0x14
#define SERVO		0x15

//LOCKED CAN INTERRUPT IDs
#define END_GAME    	 0x00
#define PLAYER_READY	 0x01
#define MULTI_ADD_POINT	 0x02
#define MULTI_GAME_MODE  0x03

//LOCKED CAN INTERRUPT DATA
#define MULTI_ETERNAL  0x01
#define MULTI_POINTS   0x02

// Functions
void can_init();

uint8_t getcan();

void can_interrupt();

void can_message_send(uint8_t buffer, can_message_t* msg);

void can_message_receive(uint8_t buffer, can_message_t* received);
